﻿namespace ExamV5.PaperInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class AddPaperRubricWhere : Page
    {
        protected Button butAddRule;
        protected Button butDefault;
        protected Button butSave;
        protected GridView DataGridInfo;
        protected DropDownList DDLDifficulty;
        protected DropDownList DDLRubricType;
        protected DropDownList DDLSubject;
        protected DropDownList DDLTemp;
        protected HtmlForm Form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private HttpCookie httpCookie_4 = null;
        private int int_0 = 0;
        protected Label labGradeA;
        protected Label labGradeB;
        protected Label labGradeC;
        protected Label labGradeD;
        protected LinkButton LBDelTemp;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLCustName;
        protected ScriptManager SM;
        private string string_0 = "A";
        private string string_1 = "1";
        protected TextBox txtAFen;
        protected TextBox txtBFen;
        protected TextBox txtCFen;
        protected TextBox txtDFen;
        protected TextBox txtGradeAMax;
        protected TextBox txtGradeAMin;
        protected TextBox txtGradeBMax;
        protected TextBox txtGradeBMin;
        protected TextBox txtGradeCMax;
        protected TextBox txtGradeCMin;
        protected TextBox txtGradeDMax;
        protected TextBox txtGradeDMin;
        protected TextBox txtValue;
        protected UpdatePanel UPPart;

        protected void butAddRule_Click(object sender, EventArgs e)
        {
            string[] strArray = this.ViewState["strRubric"].ToString().Split(new char[] { '#' });
            string str = "";
            string str2 = "";
            string str3 = "";
            int num = 0;
            if (this.RBLCustName.SelectedItem.Value == "B")
            {
                int num2;
                string str4;
                if (this.txtValue.Text.Trim() == "")
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BInput1", "alert('请输入合法的抽试题数值！')", true);
                    return;
                }
                try
                {
                    num = Convert.ToInt32(this.txtValue.Text.Trim());
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BInput2", "alert('请输入合法的抽试题数值！')", true);
                    return;
                }
                if (((this.DDLSubject.SelectedItem.Value.Trim() == "") && (this.DDLRubricType.SelectedItem.Value.Trim() == "")) && (this.DDLDifficulty.SelectedItem.Value.Trim() == ""))
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BInput3", "alert('请选择某一种规则条件！')", true);
                    return;
                }
                if (this.DDLRubricType.SelectedItem.Value.Trim() != "")
                {
                    str = str + ",题型=" + this.DDLRubricType.SelectedItem.Text;
                    str2 = str2 + " and RubricType=‘" + this.DDLRubricType.SelectedItem.Value + "’";
                }
                if (this.DDLSubject.SelectedItem.Value.Trim() == "")
                {
                    string str9 = "";
                    for (num2 = 0; num2 < this.DDLSubject.Items.Count; num2++)
                    {
                        if (this.DDLSubject.Items[num2].Value != "")
                        {
                            if (!(str9.Trim() == ""))
                            {
                                str9 = str9 + " or SubjectID=" + this.DDLSubject.Items[num2].Value;
                                str = str + " 或 科目=" + this.DDLSubject.Items[num2].Text;
                            }
                            else
                            {
                                str9 = " SubjectID=" + this.DDLSubject.Items[num2].Value;
                                str = str + ",科目=" + this.DDLSubject.Items[num2].Text;
                            }
                        }
                    }
                    str2 = str2 + " and (" + str9 + ")";
                }
                else
                {
                    str = str + ",科目=" + this.DDLSubject.SelectedItem.Text;
                    str2 = str2 + " and SubjectID=" + this.DDLSubject.SelectedItem.Value;
                }
                if (this.DDLDifficulty.SelectedItem.Value.Trim() == "")
                {
                    string str8 = "";
                    for (num2 = 0; num2 < this.DDLDifficulty.Items.Count; num2++)
                    {
                        if (this.DDLDifficulty.Items[num2].Value != "")
                        {
                            if (!(str8.Trim() == ""))
                            {
                                str8 = str8 + " or Difficulty=‘" + this.DDLDifficulty.Items[num2].Value + "’";
                            }
                            else
                            {
                                str8 = " Difficulty=‘" + this.DDLDifficulty.Items[num2].Value + "’";
                            }
                        }
                    }
                    str2 = str2 + " and (" + str8 + ")";
                }
                else
                {
                    str = str + ",难易程度=" + this.DDLDifficulty.SelectedItem.Text;
                    str2 = str2 + " and Difficulty=‘" + this.DDLDifficulty.SelectedItem.Value + "’";
                }
                str = (str + "，抽题数为：" + this.txtValue.Text.Trim() + "道").Substring(1);
                string str6 = "";
                string str5 = "";
                if (this.DDLRubricType.SelectedItem.Value.Trim() == "")
                {
                    for (num2 = 0; num2 < strArray.Length; num2++)
                    {
                        str6 = "";
                        str5 = "";
                        switch (num2.ToString())
                        {
                            case "0":
                                if ((strArray[num2].Trim() != "") && (strArray[num2].Trim() != "0"))
                                {
                                    str3 = "A";
                                    str6 = "RubricType=‘A’ " + str2;
                                    str5 = "题型=单选题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[0].Trim()))
                                {
                                    Convert.ToInt32(strArray[0].Trim());
                                }
                                break;

                            case "1":
                                if (!((strArray[num2].Trim() != "") ? !(strArray[num2].Trim() != "0") : true))
                                {
                                    str3 = "B";
                                    str6 = "RubricType=‘B’ " + str2;
                                    str5 = "题型=多选题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[1].Trim()))
                                {
                                    Convert.ToInt32(strArray[1].Trim());
                                }
                                break;

                            case "2":
                                if ((strArray[num2].Trim() != "") && (strArray[num2].Trim() != "0"))
                                {
                                    str3 = "C";
                                    str6 = "RubricType=‘C’ " + str2;
                                    str5 = "题型=判断题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[2].Trim()))
                                {
                                    Convert.ToInt32(strArray[2].Trim());
                                }
                                break;

                            case "3":
                                if (!((strArray[num2].Trim() != "") ? !(strArray[num2].Trim() != "0") : true))
                                {
                                    str3 = "D";
                                    str6 = "RubricType=‘D’ " + str2;
                                    str5 = "题型=填空题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[3].Trim()))
                                {
                                    Convert.ToInt32(strArray[3].Trim());
                                }
                                break;

                            case "4":
                                if (!((strArray[num2].Trim() != "") ? !(strArray[num2].Trim() != "0") : true))
                                {
                                    str3 = "E";
                                    str6 = "RubricType=‘E’ " + str2;
                                    str5 = "题型=简答题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[4].Trim()))
                                {
                                    Convert.ToInt32(strArray[4].Trim());
                                }
                                break;

                            case "5":
                                if (!((strArray[num2].Trim() != "") ? !(strArray[num2].Trim() != "0") : true))
                                {
                                    str3 = "F";
                                    str6 = "RubricType=‘F’ " + str2;
                                    str5 = "题型=作文题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[5].Trim()))
                                {
                                    Convert.ToInt32(strArray[5].Trim());
                                }
                                break;

                            case "6":
                                if (!((strArray[num2].Trim() != "") ? !(strArray[num2].Trim() != "0") : true))
                                {
                                    str3 = "G";
                                    str6 = "RubricType=‘G’ " + str2;
                                    str5 = "题型=论述题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[6].Trim()))
                                {
                                    Convert.ToInt32(strArray[6].Trim());
                                }
                                break;

                            case "7":
                                if ((strArray[num2].Trim() != "") && (strArray[num2].Trim() != "0"))
                                {
                                    str3 = "H";
                                    str6 = "RubricType=‘H’ " + str2;
                                    str5 = "题型=分析题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[7].Trim()))
                                {
                                    Convert.ToInt32(strArray[7].Trim());
                                }
                                break;

                            case "8":
                                if ((strArray[num2].Trim() != "") && (strArray[num2].Trim() != "0"))
                                {
                                    str3 = "I";
                                    str6 = "RubricType=‘I’ " + str2;
                                    str5 = "题型=操作题," + str;
                                }
                                if (num > Convert.ToInt32(strArray[8].Trim()))
                                {
                                    Convert.ToInt32(strArray[8].Trim());
                                }
                                break;
                        }
                        if (str6.Trim() != "")
                        {
                            str4 = "insert into PaperRule(PaperID,RuleName,RuleValue,RubricType,GetNum,GetPercNum) values";
                            str4 = string.Concat(new object[] { str4, "(", this.int_0, ",'", str5, "','", str6, "','", str3, "',", num, ",", num, ")" });
                            this.publicFun_0.ExecuteSql(str4);
                        }
                    }
                }
                else
                {
                    str6 = "";
                    int index = 0;
                    switch (this.DDLRubricType.SelectedItem.Value.Trim())
                    {
                        case "A":
                            index = 0;
                            break;

                        case "B":
                            index = 1;
                            break;

                        case "C":
                            index = 2;
                            break;

                        case "D":
                            index = 3;
                            break;

                        case "E":
                            index = 4;
                            break;

                        case "F":
                            index = 5;
                            break;

                        case "G":
                            index = 6;
                            break;

                        case "H":
                            index = 7;
                            break;

                        case "I":
                            index = 8;
                            break;
                    }
                    str3 = this.DDLRubricType.SelectedItem.Value.Trim();
                    str6 = "RubricType=‘" + this.DDLRubricType.SelectedItem.Value.Trim() + "’ " + str2;
                    if (num > Convert.ToInt32(strArray[index].Trim()))
                    {
                        Convert.ToInt32(strArray[index].Trim());
                    }
                    if (str6.Trim() != "")
                    {
                        str4 = "insert into PaperRule(PaperID,RuleName,RuleValue,RubricType,GetNum,GetPercNum) values";
                        str4 = string.Concat(new object[] { str4, "(", this.int_0, ",'", str, "','", str6, "','", str3, "',", num, ",", num, ")" });
                        this.publicFun_0.ExecuteSql(str4);
                    }
                }
            }
            this.method_0();
            this.DDLRubricType.SelectedIndex = -1;
            this.DDLDifficulty.SelectedIndex = -1;
            this.DDLSubject.SelectedIndex = -1;
            this.DDLRubricType.SelectedIndex = 0;
            this.DDLDifficulty.SelectedIndex = 0;
            this.DDLSubject.SelectedIndex = 0;
            this.txtValue.Text = "";
        }

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string str2;
            string strSql = string.Concat(new object[] { "delete GradeReule where PaperID=", this.int_0, ";insert into GradeReule(ReuleName,MinValue,MaxValue,PaperID,StandFlag,StudyFen) values('", this.labGradeA.Text.Trim(), "',", this.txtGradeAMin.Text.Trim(), ",", this.txtGradeAMax.Text.Trim(), ",", this.int_0, ",'A',", this.txtAFen.Text.Trim(), ")" });
            strSql = string.Concat(new object[] { strSql, ";insert into GradeReule(ReuleName,MinValue,MaxValue,PaperID,StandFlag,StudyFen) values('", this.labGradeB.Text.Trim(), "',", this.txtGradeBMin.Text.Trim(), ",", this.txtGradeBMax.Text.Trim(), ",", this.int_0, ",'B',", this.txtBFen.Text.Trim(), ")" });
            strSql = string.Concat(new object[] { strSql, ";insert into GradeReule(ReuleName,MinValue,MaxValue,PaperID,StandFlag,StudyFen) values('", this.labGradeC.Text.Trim(), "',", this.txtGradeCMin.Text.Trim(), ",", this.txtGradeCMax.Text.Trim(), ",", this.int_0, ",'C',", this.txtCFen.Text.Trim(), ")" });
            strSql = string.Concat(new object[] { strSql, ";insert into GradeReule(ReuleName,MinValue,MaxValue,PaperID,StandFlag,StudyFen) values('", this.labGradeD.Text.Trim(), "',", this.txtGradeDMin.Text.Trim(), ",", this.txtGradeDMax.Text.Trim(), ",", this.int_0, ",'D',", this.txtDFen.Text.Trim(), ")" });
            this.publicFun_0.ExecuteSql(strSql);
            if (this.RBLCustName.SelectedItem.Value == "A")
            {
                this.publicFun_0.ExecuteSql("delete PaperRule where PaperID=" + this.int_0);
                str2 = base.Request.Url.ToString();
                str2 = str2.Substring(0, str2.LastIndexOf('/') + 1);
                base.Response.Redirect(string.Concat(new object[] { str2, "FrmAddUserJoinExam.aspx?AddType=R&IsRead=", this.string_1, "&RuleCust=", this.RBLCustName.SelectedItem.Value, "&ID=", this.int_0, "&ExamType=", this.string_0 }));
            }
            else
            {
                int num;
                for (int i = 0; i < this.DDLSubject.Items.Count; i++)
                {
                    if ((this.DDLSubject.Items[i].Value.Trim() != "") && (this.publicFun_0.GetValues(string.Concat(new object[] { "select ID from PaperRule where RuleValue like '%SubjectID=", this.DDLSubject.Items[i].Value, "%' and PaperID=", this.int_0 }), "ID").Trim() == ""))
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSubjectB1", "alert('规则中未找到相应的科目信息！')", true);
                        return;
                    }
                }
                string[] strArray3 = this.ViewState["strRubric"].ToString().Split(new char[] { '#' });
                for (num = 0; num < this.DDLRubricType.Items.Count; num++)
                {
                    if (this.DDLRubricType.Items[num].Value.Trim() != "")
                    {
                        string values = this.publicFun_0.GetValues(string.Concat(new object[] { "select sum(GetPercNum) as GetPercNum from PaperRule where RubricType='", this.DDLRubricType.Items[num].Value.Trim(), "' and PaperID=", this.int_0 }), "GetPercNum");
                        switch (this.DDLRubricType.Items[num].Value.Trim())
                        {
                            case "A":
                                if (!(strArray3[0].Trim() != values.Trim()))
                                {
                                    break;
                                }
                                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust1", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                return;

                            case "B":
                                if (!(strArray3[1].Trim() != values.Trim()))
                                {
                                    break;
                                }
                                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust2", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                return;

                            case "C":
                                if (strArray3[2].Trim() != values.Trim())
                                {
                                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust3", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                    return;
                                }
                                break;

                            case "D":
                                if (strArray3[3].Trim() != values.Trim())
                                {
                                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust4", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                    return;
                                }
                                break;

                            case "E":
                                if (!(strArray3[4].Trim() != values.Trim()))
                                {
                                    break;
                                }
                                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust5", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                return;

                            case "F":
                                if (strArray3[5].Trim() != values.Trim())
                                {
                                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust6", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                    return;
                                }
                                break;

                            case "G":
                                if (strArray3[6].Trim() != values.Trim())
                                {
                                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust7", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                    return;
                                }
                                break;

                            case "H":
                                if (!(strArray3[7].Trim() != values.Trim()))
                                {
                                    break;
                                }
                                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust8", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                return;

                            case "I":
                                if (strArray3[8].Trim() != values.Trim())
                                {
                                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust9", "alert('[" + this.DDLRubricType.Items[num].Text + "]定义规则未达到或超出定义数！')", true);
                                    return;
                                }
                                break;
                        }
                    }
                }
                string[] strArray = this.ViewState["strRubric"].ToString().Split(new char[] { '#' });
                string str4 = "";
                string str3 = "";
                string str5 = "";
                if (this.string_1.Trim() == "1")
                {
                    str4 = "select count(*) as RubricCount from RubricInfo where IsDel='N' and Flag='" + this.string_0 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                    str3 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_0 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                }
                else
                {
                    str4 = "select count(*) as RubricCount from RubricInfo where IsDel='N' and Flag='" + this.string_0 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                    str3 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_0 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                }
                for (num = 0; num < strArray.Length; num++)
                {
                    switch (num)
                    {
                        case 0:
                            str5 = "A";
                            break;

                        case 1:
                            str5 = "B";
                            break;

                        case 2:
                            str5 = "C";
                            break;

                        case 3:
                            str5 = "D";
                            break;

                        case 4:
                            str5 = "E";
                            break;

                        case 5:
                            str5 = "F";
                            break;

                        case 6:
                            str5 = "G";
                            break;

                        case 7:
                            str5 = "H";
                            break;

                        case 8:
                            str5 = "I";
                            break;
                    }
                    if ((strArray[num].Trim() != "") && (strArray[num].Trim() != "0"))
                    {
                        string str6 = str4 + " and RubricType='" + str5 + "'";
                        string str7 = this.method_5(str6, str5);
                        if (str7 != "0")
                        {
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust219", "alert('〖" + str7 + "〗题库中的题数暂不能满足部分规则条件,请重新定义规则条件！')", true);
                            return;
                        }
                    }
                }
                if (this.method_4(this.int_0, str3) != 0)
                {
                    strSql = string.Concat(new object[] { "delete from PaperRule where PaperID=", this.int_0, ";Delete from PaperInfo where ID=", this.int_0, ";delete from SysTip where Formtable='PaperInfo' and FormID=", this.int_0 });
                    this.publicFun_0.ExecuteSql(strSql);
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust219", "alert('新建随机组卷信息失败！')", true);
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCust09", "setTimeout(function(){window.location='RndAddPaper.aspx'},500)')", true);
                }
                else
                {
                    str2 = base.Request.Url.ToString();
                    str2 = str2.Substring(0, str2.LastIndexOf('/') + 1);
                    base.Response.Redirect(string.Concat(new object[] { str2, "FrmAddUserJoinExam.aspx?AddType=R&IsRead=", this.string_1, "&RuleCust=", this.RBLCustName.SelectedItem.Value, "&ID=", this.int_0, "&ExamType=", this.string_0 }));
                }
            }
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            if (!(this.RBLCustName.SelectedItem.Value != "B"))
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BShowTemp", "ShowRuleTemp(" + this.int_0 + ")", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSaveTemp", "alert('抽题规则为人工自定义时才可保存！')", true);
            }
        }

        protected void DataGridInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.DataGridInfo.PageIndex = e.NewPageIndex;
            this.method_0();
        }

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItemIndex == -1)
            {
                this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
                this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
                if ((e.Row.DataItemIndex % 2) == 0)
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
                }
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton button = (LinkButton) e.Row.Cells[1].FindControl("LBDel");
                button.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除规则信息吗？')==false) return false;}");
            }
        }

        protected void DataGridInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            this.publicFun_0.ExecuteSql("Delete from PaperRule  where ID='" + this.DataGridInfo.DataKeys[e.RowIndex]["ID"].ToString() + "'");
            this.DataGridInfo.PageIndex = 0;
            this.method_0();
        }

        protected void DDLTemp_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!(this.DDLTemp.SelectedItem.Value != "0"))
            {
                this.publicFun_0.ExecuteSql("delete PaperRule where PaperID=" + this.int_0);
                this.method_0();
                this.LBDelTemp.Visible = false;
            }
            else
            {
                this.publicFun_0.ExecuteSql(string.Concat(new object[] { "delete PaperRule where PaperID=", this.int_0, ";insert into PaperRule(PaperID,RuleName,RuleValue,GetNum,GetPercNum,RubricType) select ", this.int_0, ",RuleName,RuleValue,GetNum,GetPercNum,RubricType from RuleTemp where UPID=", this.DDLTemp.SelectedItem.Value }));
                this.method_0();
                this.LBDelTemp.Visible = true;
            }
        }

        protected void LBDelTemp_Click(object sender, EventArgs e)
        {
            this.publicFun_0.ExecuteSql("delete RuleTitle where ID=" + this.DDLTemp.SelectedItem.Value + ";delete RuleTemp  where UPID=" + this.DDLTemp.SelectedItem.Value);
            this.method_1();
            this.LBDelTemp.Visible = false;
        }

        private void method_0()
        {
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter("select ID,RuleName from PaperRule where PaperID=" + this.int_0 + " ", selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "PaperInfo");
            this.DataGridInfo.DataSource = dataSet.Tables["PaperInfo"].DefaultView;
            this.DataGridInfo.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
        }

        private void method_1()
        {
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter("select ID,RuleName from RuleTitle where Flag='A' or InputUserCode='" + this.httpCookie_0.Value + "'", selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "RuleTitle");
            this.DDLTemp.DataTextField = "RuleName";
            this.DDLTemp.DataValueField = "ID";
            this.DDLTemp.DataSource = dataSet.Tables["RuleTitle"].DefaultView;
            this.DDLTemp.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
            this.DDLTemp.Items.Insert(0, new ListItem("--请选择规则模板--", "0"));
        }

        private void method_2()
        {
            int num;
            string str = "";
            string str2 = "";
            string str3 = "A#B#C#D#E";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select SubjectID,SubjectName,RubricDist from PaperInfo where ID=" + this.int_0, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                str = reader["RubricDist"].ToString();
                this.ViewState["strRubric"] = str;
                reader["SubjectName"].ToString();
                str2 = reader["SubjectID"].ToString();
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
            string[] strArray3 = str.Split(new char[] { '#' });
            string[] strArray = str3.Split(new char[] { '#' });
            string[] strArray2 = str2.Split(new char[] { ',' });
            for (num = 0; num < strArray3.Length; num++)
            {
                string text = "";
                string str10 = "";
                switch (num.ToString())
                {
                    case "0":
                        text = "单选题";
                        str10 = "A";
                        break;

                    case "1":
                        text = "多选题";
                        str10 = "B";
                        break;

                    case "2":
                        text = "判断题";
                        str10 = "C";
                        break;

                    case "3":
                        text = "填空题";
                        str10 = "D";
                        break;

                    case "4":
                        text = "简答题";
                        str10 = "E";
                        break;

                    case "5":
                        text = "作文题";
                        str10 = "F";
                        break;

                    case "6":
                        text = "论述题";
                        str10 = "G";
                        break;

                    case "7":
                        text = "分析题";
                        str10 = "H";
                        break;

                    case "8":
                        text = "操作题";
                        str10 = "I";
                        break;

                    default:
                        text = "";
                        str10 = "";
                        this.ViewState["RubricJ"] = strArray3[9].Trim();
                        break;
                }
                if (((strArray3[num].Trim() != "") && (strArray3[num].Trim() != "0")) && (text.Trim() != ""))
                {
                    ListItem item9 = new ListItem(text, str10);
                    this.DDLRubricType.Items.Add(item9);
                    if (str6.Trim().Length == 0)
                    {
                        str6 = " (RubricType='" + str10 + "'";
                    }
                    else
                    {
                        str6 = str6 + " or RubricType='" + str10 + "'";
                    }
                }
            }
            if (str6.Trim() != "")
            {
                str6 = str6 + ")";
            }
            else
            {
                str6 = " ID<>0 ";
            }
            this.ViewState["strSqlRubricType"] = str6;
            ListItem item8 = new ListItem("默认所有题型", "");
            this.DDLRubricType.Items.Insert(0, item8);
            string str9 = "";
            str4 = "";
            for (num = 0; num < strArray2.Length; num++)
            {
                if (strArray2[num].Trim() != "")
                {
                    if (str9.Trim().Length == 0)
                    {
                        str9 = " (ID='" + strArray2[num].Trim() + "' ";
                        str4 = " ( SubjectID=" + strArray2[num].Trim();
                    }
                    else
                    {
                        str9 = str9 + " or ID='" + strArray2[num].Trim() + "' ";
                        str4 = str4 + " or SubjectID=" + strArray2[num].Trim();
                    }
                }
            }
            if (str9.Trim() != "")
            {
                str9 = str9 + ")";
                str4 = str4 + ")";
            }
            else
            {
                str9 = " ID<>0 ";
                str4 = " SubjectID<>0 ";
            }
            this.DDLSubject.DataTextField = "SubjectName";
            this.DDLSubject.DataValueField = "ID";
            this.DDLSubject.DataSource = this.publicFun_0.RetrunDataView("select ID,SubjectName from SubjectInfo where " + str9 + " order by ID desc");
            this.DDLSubject.DataBind();
            this.ViewState["strSqlSubject"] = str4;
            ListItem item7 = new ListItem("默认当前所选科目", "");
            this.DDLSubject.Items.Insert(0, item7);
            for (num = 0; num < strArray.Length; num++)
            {
                switch (strArray[num].Trim())
                {
                    case "E":
                    {
                        ListItem item6 = new ListItem("容易", "E");
                        this.DDLDifficulty.Items.Add(item6);
                        if (str5.Trim().Length != 0)
                        {
                            str5 = str5 + " or Difficulty='E' ";
                        }
                        else
                        {
                            str5 = " (Difficulty='E' ";
                        }
                        break;
                    }
                    case "D":
                    {
                        ListItem item5 = new ListItem("较易", "D");
                        this.DDLDifficulty.Items.Add(item5);
                        if (str5.Trim().Length == 0)
                        {
                            str5 = " (Difficulty='D' ";
                        }
                        else
                        {
                            str5 = str5 + " or Difficulty='D' ";
                        }
                        break;
                    }
                    case "C":
                    {
                        ListItem item4 = new ListItem("中等", "C");
                        this.DDLDifficulty.Items.Add(item4);
                        if (str5.Trim().Length != 0)
                        {
                            str5 = str5 + " or Difficulty='C' ";
                        }
                        else
                        {
                            str5 = " (Difficulty='C' ";
                        }
                        break;
                    }
                    case "B":
                    {
                        ListItem item3 = new ListItem("较难", "B");
                        this.DDLDifficulty.Items.Add(item3);
                        if (str5.Trim().Length == 0)
                        {
                            str5 = " (Difficulty='B' ";
                        }
                        else
                        {
                            str5 = str5 + " or Difficulty='B' ";
                        }
                        break;
                    }
                    case "A":
                    {
                        ListItem item2 = new ListItem("难", "A");
                        this.DDLDifficulty.Items.Add(item2);
                        if (str5.Trim().Length != 0)
                        {
                            str5 = str5 + " or Difficulty='A' ";
                        }
                        else
                        {
                            str5 = " (Difficulty='A' ";
                        }
                        break;
                    }
                }
            }
            if (!(str5.Trim() != ""))
            {
                str5 = " ID<>0 ";
            }
            else
            {
                str5 = str5 + ")";
            }
            this.ViewState["strSqlDifficulty"] = str5;
            ListItem item = new ListItem("默认所有难易程度", "");
            this.DDLDifficulty.Items.Insert(0, item);
        }

        private void method_3()
        {
            string cmdText = "";
            if (!(this.publicFun_0.GetValues("select ID from GradeReule where PaperID=" + this.int_0, "ID") != ""))
            {
                cmdText = "select * from GradeReule where PaperID=0";
            }
            else
            {
                cmdText = "select * from GradeReule where PaperID=" + this.int_0;
            }
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(cmdText, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                string str2 = reader["StandFlag"].ToString().Trim();
                switch (str2)
                {
                    case null:
                    {
                        continue;
                    }
                    case "A":
                    {
                        this.labGradeA.Text = reader["ReuleName"].ToString();
                        this.txtGradeAMin.Text = reader["MinValue"].ToString();
                        this.txtGradeAMax.Text = reader["MaxValue"].ToString();
                        this.txtAFen.Text = reader["StudyFen"].ToString();
                        continue;
                    }
                }
                if (str2 != "B")
                {
                    if (!(str2 == "C"))
                    {
                        if (str2 == "D")
                        {
                            this.labGradeD.Text = reader["ReuleName"].ToString();
                            this.txtGradeDMin.Text = reader["MinValue"].ToString();
                            this.txtGradeDMax.Text = reader["MaxValue"].ToString();
                            this.txtDFen.Text = reader["StudyFen"].ToString();
                        }
                    }
                    else
                    {
                        this.labGradeC.Text = reader["ReuleName"].ToString();
                        this.txtGradeCMin.Text = reader["MinValue"].ToString();
                        this.txtGradeCMax.Text = reader["MaxValue"].ToString();
                        this.txtCFen.Text = reader["StudyFen"].ToString();
                    }
                }
                else
                {
                    this.labGradeB.Text = reader["ReuleName"].ToString();
                    this.txtGradeBMin.Text = reader["MinValue"].ToString();
                    this.txtGradeBMax.Text = reader["MaxValue"].ToString();
                    this.txtBFen.Text = reader["StudyFen"].ToString();
                }
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        private int method_4(int int_1, string string_2)
        {
            SqlDataReader reader;
            SqlCommand command;
            SqlConnection connection2;
            string str14;
            int count;
            int num5;
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string str10 = "";
            int num2 = 0;
            string[] strArray = this.ViewState["strRubric"].ToString().Split(new char[] { '#' });
            string strSql = "";
            string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            SqlConnection selectConnection = new SqlConnection(connectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='A'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter9 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter9 = new SqlDataAdapter(string_2 + "  and (" + str10 + ")", selectConnection);
                    adapter9.Fill(dataSet, "AExamData");
                    count = dataSet.Tables["AExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["AExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str.IndexOf("#" + str14, 0) == -1)
                        {
                            str = str + str14;
                            num2--;
                        }
                    }
                    adapter9.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='B'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter8 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter8 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter8.Fill(dataSet, "BExamData");
                    count = dataSet.Tables["BExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["BExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str2.IndexOf("#" + str14, 0) == -1)
                        {
                            str2 = str2 + str14;
                            num2--;
                        }
                    }
                    adapter8.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='C'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter7 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter7 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter7.Fill(dataSet, "CExamData");
                    count = dataSet.Tables["CExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["CExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str3.IndexOf("#" + str14, 0) == -1)
                        {
                            str3 = str3 + str14;
                            num2--;
                        }
                    }
                    adapter7.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='D'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter6 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter6 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter6.Fill(dataSet, "DExamData");
                    count = dataSet.Tables["DExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["DExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str4.IndexOf("#" + str14, 0) == -1)
                        {
                            str4 = str4 + str14;
                            num2--;
                        }
                    }
                    adapter6.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='E'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter5 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter5 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter5.Fill(dataSet, "EExamData");
                    count = dataSet.Tables["EExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["EExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str5.IndexOf("#" + str14, 0) == -1)
                        {
                            str5 = str5 + str14;
                            num2--;
                        }
                    }
                    adapter5.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='F'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter4 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter4 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter4.Fill(dataSet, "FExamData");
                    count = dataSet.Tables["FExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["FExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str6.IndexOf("#" + str14, 0) == -1)
                        {
                            str6 = str6 + str14;
                            num2--;
                        }
                    }
                    adapter4.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='G'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter3 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter3 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter3.Fill(dataSet, "GExamData");
                    count = dataSet.Tables["GExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["GExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str7.IndexOf("#" + str14, 0) == -1)
                        {
                            str7 = str7 + str14;
                            num2--;
                        }
                    }
                    adapter3.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='H'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter2 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter2 = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter2.Fill(dataSet, "HExamData");
                    count = dataSet.Tables["HExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["HExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str8.IndexOf("#" + str14, 0) == -1)
                        {
                            str8 = str8 + str14;
                            num2--;
                        }
                    }
                    adapter2.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='I'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter = new SqlDataAdapter(string_2 + " and (" + str10 + ")", selectConnection);
                    adapter.Fill(dataSet, "IExamData");
                    count = dataSet.Tables["IExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["IExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str9.IndexOf("#" + str14, 0) == -1)
                        {
                            str9 = str9 + str14;
                            num2--;
                        }
                    }
                    adapter.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string str13 = this.ViewState["RubricJ"].ToString().Trim();
            if (str13 != "0")
            {
                str13 = str13.Trim().Replace("_", "#") + "#";
            }
            else
            {
                str13 = "";
            }
            if (str.Length <= 1)
            {
                str = "";
            }
            else
            {
                str = str.Substring(1);
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length <= 1)
            {
                str4 = "";
            }
            else
            {
                str4 = str4.Substring(1);
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length > 1)
            {
                str6 = str6.Substring(1);
            }
            else
            {
                str6 = "";
            }
            if (str7.Length > 1)
            {
                str7 = str7.Substring(1);
            }
            else
            {
                str7 = "";
            }
            if (str8.Length > 1)
            {
                str8 = str8.Substring(1);
            }
            else
            {
                str8 = "";
            }
            if (str9.Length <= 1)
            {
                str9 = "";
            }
            else
            {
                str9 = str9.Substring(1);
            }
            try
            {
                strSql = string.Concat(new object[] { "delete from PaperDataTmp where PaperID=", int_1, ";Insert into PaperDataTmp(PaperID,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ) values(", int_1 });
                strSql = strSql + ",'" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + str13 + "')";
                this.publicFun_0.ExecuteSql(strSql);
                return 0;
            }
            catch
            {
                return 1;
            }
        }

        private string method_5(string string_2, string string_3)
        {
            string str = "";
            string str2 = "";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(string.Concat(new object[] { "select RuleName,RuleValue,GetNum from PaperRule where PaperID=", this.int_0, " and RubricType='", string_3, "'" }), connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                str = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                if (Convert.ToInt32(reader["GetNum"].ToString().Trim()) > Convert.ToInt32(this.publicFun_0.GetValues(string_2 + " and (" + str + ")", "RubricCount")))
                {
                    str2 = reader["RuleName"].ToString().Trim();
                }
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
            if (str2.Trim() == "")
            {
                str2 = "0";
            }
            return str2;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_3 = new HttpCookie("ExamUserLevel");
            this.httpCookie_3 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_4 = new HttpCookie("ExamDeptID");
            this.httpCookie_4 = base.Request.Cookies["ExamDeptID"];
            this.httpCookie_2 = new HttpCookie("ExamDeptName");
            this.httpCookie_2 = base.Request.Cookies["ExamDeptName"];
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.httpCookie_4.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_4.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
                this.string_0 = base.Request["ExamType"].ToString();
                this.string_1 = base.Request["IsRead"].ToString();
                if (!base.IsPostBack)
                {
                    this.ViewState["strRubric"] = "";
                    this.ViewState["strSqlRubricType"] = "";
                    this.ViewState["strSqlSubject"] = "";
                    this.ViewState["strSqlDifficulty"] = "";
                    this.method_3();
                    this.publicFun_0.ExecuteSql("delete from PaperRule where PaperID=" + this.int_0);
                    this.method_2();
                    this.method_1();
                    this.method_0();
                    this.butDefault.Attributes.Add("onclick", "javascript:{if(confirm('确定试卷参数无误，要进行下一步吗？')==false) return false;}");
                    this.LBDelTemp.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除规则模板吗？')==false) return false;}");
                }
                else
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
            }
        }
    }
}

